import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.*;
import javax.sound.sampled.*;


public class Recorder extends Thread 
{
 TargetDataLine	m_line;
 AudioFileFormat.Type	m_targetType;
 File			m_file;
 boolean		m_bRecording;
 AudioInputStream	m_audioInputStream;
 public Recorder(TargetDataLine line)
	{
	m_line = line;
	m_targetType = AudioFileFormat.Type.WAVE;
	m_file = new File("RecordedFile");
	m_audioInputStream = new AudioInputStream(line);
	}
 public void start()
	{
	m_line.start();
	super.start();
	}
 public void stopRecording()
	{
	m_line.stop();
	m_line.drain();
	m_line.close();
	m_bRecording = false;
	}
 public void run()
	{
	try
		{
		AudioSystem.write(m_audioInputStream,m_targetType,m_file);
		}
	catch (IOException e)
		{
		e.printStackTrace();
		}
	}
}